//
//  DMFeedbackVC.m
//  DistributionMall
//
//  Created by JHnoplan on 2018/10/17.
//  Copyright © 2018年 JHnoplan. All rights reserved.
//

#import "DMFeedbackVC.h"

@interface DMFeedbackVC ()<UITextViewDelegate>

@property (weak, nonatomic) IBOutlet UILabel *placeholderLb;
@property (weak, nonatomic) IBOutlet UITextView *mainTV;
@property (weak, nonatomic) IBOutlet UIImageView *firstImage;
@property (weak, nonatomic) IBOutlet UIImageView *secondImage;
@property (weak, nonatomic) IBOutlet UIImageView *thirdImage;
@property (weak, nonatomic) IBOutlet UIImageView *fourthImage;
@property (weak, nonatomic) IBOutlet UITextField *secondTF;

@end

@implementation DMFeedbackVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self startInit];
}

-(void)startInit {
    
    self.navigationItem.title = @"意见反馈";
    self.view.backgroundColor = DMDefaultColor;
    _mainTV.delegate = self;
    
    NSArray *arr = @[_firstImage, _secondImage, _thirdImage, _fourthImage];
    for (int i = 0; i < arr.count; i++) {
        UIImageView *iv = arr[i];
        iv.userInteractionEnabled = YES;
        iv.tag = 100+i;
        [iv addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapClick:)]];
    }

}

-(void)tapClick:(UITapGestureRecognizer *)tap {
    [_mainTV resignFirstResponder];
    
    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"更换头像" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    }];
    [actionSheet addAction:action1];
    [actionSheet addAction:action2];
    [actionSheet addAction:action3];
    [self presentViewController:actionSheet animated:YES completion:nil];
}

- (IBAction)submitClick:(UIButton *)sender {
    
    DMSucceedVC *vc = [DMSucceedVC new];
    vc.typeIndex = feedbackSucceed;
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)textViewDidChange:(UITextView *)textView {
    if (textView.text.length == 0) {
        _placeholderLb.hidden = NO;
    }else {
        _placeholderLb.hidden = YES;
    }
}

@end
